using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Microsoft.DirectX.DirectDraw;
using TowerDefense_Dx.Core;

namespace TowerDefense_Dx.GameLogic
{
    public class Player
    {
        private int _money ;
        public int Money
        {
            get { return _money; }
            set { _money = value; }
        }
        private int _lives;
        public int Lives
        {
            get { return _lives; }
            set { _lives = value; }
        }
        private DxInitGraphics _graphic;
        private List<Tower> _towerList = new List<Tower>();
        public List<Tower> TowerList
        {
            get { return _towerList; }
            set { _towerList = value; }
        }
        public Player(DxInitGraphics graphic)
        {
            _graphic = graphic;
            _money = 25;
            _lives = 10;
        }
        public void Update(double deltaTime, List<Enemy> enemyList)
        {
            for (int i = 0; i < _towerList.Count; i++)
            {
                if (enemyList != null)
                {
                    _towerList[i].Update(deltaTime, enemyList);
                }
                _towerList[i].BulletUpdate(_towerList[i].Target);
            }
        }
        public void DrawTower(Surface destSurface)
        {
            for (int i = 0; i < _towerList.Count; i++)
            {
                _towerList[i].DrawFast((int)_towerList[i].Position.X, (int)_towerList[i].Position.Y, 1, destSurface, DrawFastFlags.Wait);
                _towerList[i].DrawBullet(destSurface);
                destSurface.DrawCircle((int)_towerList[i].Center.X, (int)_towerList[i].Center.Y,(int) _towerList[i].Range);
            }
        }
        public void AddTower(PointF posittion)
        {
            Tower t = new Tower("Sprite/sprite.png", _graphic.GraphicsDevice, 32, 32, posittion, 300);           
            _towerList.Add(t);           
        }
        public void GetBounty(Enemy target)
        {
            _money += target.BountyScore;
        }
    }
}
